<!DOCTYPE html>
<html>

<head>

    <title>患者列表</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no">
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="0">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" type="text/css" href="css/patientList.css" />
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        img {
            float: left;
            border: 1px gray solid;

        }

        h4 {
            padding-top: 0.5rem;
        }
    </style>
</head>

<body>
    <div id="app">
        <el-button @click="close()" style="float: left;">X</el-button>
        <h4>患者列表</h4>
        <div class="search">

            <el-input :onkeyup="searchList()" v-model="input" prefix-icon="el-icon-search" icon="el-icon-search"
                placeholder="请输入姓名进行搜索">
            </el-input>

        </div>
        <el-table :data="tableData" stripe style="width: 100%">

            <el-table-column prop="patientsName" label="姓名">
            </el-table-column>
            <el-table-column prop="patientsSex" :formatter="formatRole" label="性别">
            </el-table-column>
            <el-table-column prop="patientsBirthday" label="出生日期">
            </el-table-column>
            <el-table-column prop="patientsMobile" label="手机">
            </el-table-column>
            <el-table-column align="center" label="操作" width="250" class-name="small-padding">
                <template slot-scope="scope">
                    <el-button type="info" size="mini" plain @click="gotoManagerPage(scope.row)">查看</el-button>

                </template>
            </el-table-column>
            <!-- <el-table-column align="center" label="操作" width="250" class-name="small-padding">
                <template slot-scope="scope">
                    <el-button type="info" size="mini" plain @click="updatePatientInfo(scope.row)">编辑</el-button>

                </template>
            </el-table-column> -->

        </el-table>

    </div>

</body>
<script src="../common/js/api/vue3-axios-utils.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {

            return {
                input: '',

                tableData: []
            };
        },
        methods: {
            searchList() {
                var token = localStorage.getItem("token");
                // if (this.input == '') {

                //     axios({
                //         url: spliceUrl('/100/12/1001201'),
                //         method: 'post',
                //         headers: {
                //             'X-Access-Token': token,
                //         },
                //         data: {

                //             groupId: '1',
                //         }
                //     }).then(response => {
                //         this.tableData = response.data.result.records;
                //         console.log(response.data.result.records);
                //     }).catch(error => {
                //         console.log(error);
                //     })
                // } else {


                axios({

                    url: spliceUrl('/100/12/1001201'),
                    method: 'post',
                    headers: {
                        'X-Access-Token': token,
                    },
                    data: {
                        groupId: '1',
                        keyWord: this.input,
                    }
                }).then(response => {

                    this.tableData = response.data.result.records;
                    console.log(response.data.result);


                }).catch(error => {
                    console.log(error);
                })
                // }
            },
            //根据接口返回值判断性别
            formatRole: function (row, column) {
                return row.patientsSex == '1' ? "男" : row.patientsSex == '2' ? "女" : "";
            },
            //关闭当前页面
            CloseWebPage() {
                if (navigator.userAgent.indexOf("MSIE") > 0) {
                    if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
                        window.opener = null;
                        window.close();
                    } else {
                        window.open('', '_top');
                        window.top.close();
                    }
                }
                else if (navigator.userAgent.indexOf("Firefox") > 0) {
                    window.location.href = 'about:blank ';
                } else {
                    window.opener = null;
                    window.open('', '_self', '');
                    window.close();
                }
            },
            close() {


                // window.close();



                this.$confirm('此操作关闭当前页面, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.CloseWebPage()
                    // window.opener = null;
                    // window.open('', '_self');
                    // window.close();
                    // window.close();
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });


            },
            //操作跳转
            gotoManagerPage: function (row) {

                window.location.href = './plan.html?patientId=' + row.patientId;
            },

            // GetRequest() {
            //     var token = localStorage.getItem("token");

            //     // axios.post(spliceUrl('/100/12/1001201'), {
            //     //     headers: {
            //     //         'X-Access-Token': token,
            //     //     },
            //     // }).then(response => {
            //     //     console.log(response);
            //     // }).catch(error => {
            //     //     console.log(error);
            //     // })

            //     axios({
            //         url: spliceUrl('/100/12/1001201'),
            //         method: 'post',
            //         headers: {
            //             'X-Access-Token': token,
            //         },
            //         data: {

            //             groupId: '1',
            //         }
            //     }).then(response => {
            //         this.tableData = response.data.result.records;
            //         console.log(response.data.result.records);
            //     }).catch(error => {
            //         console.log(error);
            //     })
            // }
        },


    })
</script>
<script>

    // console.log(token);
    // window.open = GetRequest();

</script>

</html>